<template>
    <div class="box1">
        <div class="title">
            <p>男女比例</p>
            <p><img src="../../images/dataScreen-title.png" alt=""></p>
        </div>
        <div class="sex">
            <div class="man"><img src="../../images/man.png" alt=""></div>
            <div class="women"><img src="../../images/woman.png" alt=""></div>
        </div>
        <div class="rate">
            <p>男士58%</p>
            <p>女生42%</p>
        </div>
        <div class="charts" ref="charts"></div>
    </div>
</template>

<script setup lang="ts">
import { ref, onMounted } from 'vue';
import * as echarts from 'echarts'

let charts = ref();
onMounted(() => {
    // 初始化echarts实例
    let mycharts = echarts.init(charts.value);
    mycharts.setOption({
        title: {
            text: '男女比例',//主标题
            textStyle: {
                color: 'skyblue'
            },
            left: '40%'
        },
        xAxis: {
            show: false,
            min: 0,
            max: 100
        },
        yAxis: {
            show: false,
            type: 'category'
        },
        series: [
            {
                type: 'bar',//图表类型为柱状图
                data:[58],
                barWidth:20,//柱子的宽度为20
                z:100,//堆叠顺序（或层级覆盖女性比例
                itemStyle:{
                    color:'skyblue',
                    borderRadius:20
                }
            },
            {
                type: 'bar',
                data:[100],
                barWidth:20,
                // z:100,
                // 调整柱条位置
                barGap:'-100%',//用于调整柱子间的间隙。让男条柱覆盖女的
                itemStyle:{
                    color:'pink',
                    borderRadius:20
                }
            }
        
        ],
        grid:{
            left:0,
            top:0,
            right:0,
            bottom:0
        }

    })
})
</script>

<style scoped lang="scss">
.box1 {
    background: url(../../images/dataScreen-main-cb.png) no-repeat;
    background-size: 100% 100%;
    margin: 20px 0;

    .title {
        margin-left: 20px;
        color: white;
        font-size: 20px;
    }

    .sex {
        display: flex;
        justify-content: center;

        .man {
            width: 111px;
            height: 115px;
            margin: 20px;
            display: flex;
            justify-content: center;
            align-items: center;
            background: url(../../images/man-bg.png) no-repeat;
            // background-size: 100% 100%;
        }

        .women {
            width: 111px;
            height: 115px;
            margin: 20px;
            display: flex;
            justify-content: center;
            align-items: center;
            background: url(../../images/woman-bg.png) no-repeat;
            // background-size: 100% 100%;
        }
    }

    .rate {
        display: flex;
        justify-content: space-between;
        color: white;

    }

    .charts {

        height: 100px;

    }
}
</style>